package com.ccit.paas.controller;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;

public class ExcelToSql {

    public static void main(String[] args) {
        String filePath = "C:\\Users\\user\\Downloads\\a.xlsx"; // Excel文件路径
        HashSet<String> billCodes = new HashSet<>();

        try (FileInputStream fis = new FileInputStream(filePath);
             Workbook workbook = new XSSFWorkbook(fis)) {

            Sheet sheet = workbook.getSheetAt(0); // 读取第一个sheet

            // 从第2行开始（假设第1行是表头：src_bill_code）
            for (int i = 1; i <= sheet.getLastRowNum(); i++) {
                Row row = sheet.getRow(i);
                if (row != null) {
                    Cell cell = row.getCell(0); // 第一列
                    if (cell != null) {
                        cell.setCellType(CellType.STRING); // 转成字符串
                        String value = cell.getStringCellValue().trim();
                        if (!value.isEmpty()) {
                            billCodes.add(value);
                        }
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

